import 'package:amap_flutter_map/amap_flutter_map.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yp/pages/mall_app/hall_map/state.dart';

class HallMapLogic extends GetxController {
  final state = HallMapState();

  @override
  void onInit() {
    super.onInit();
    state.data = Get.arguments;
    state.lng = double.parse(state.data['maplocation_x']);
    state.lat = double.parse(state.data['maplocation_y']);
  }

  AMapController _mapController;
  void onMapCreated(AMapController controller) {
    _mapController = controller;
    getApprovalNumber();
    update();
  }

  /// 获取审图号
  void getApprovalNumber() async {
    //普通地图审图号
    String mapContentApprovalNumber =
        await _mapController?.getMapContentApprovalNumber();
    //卫星地图审图号
    String satelliteImageApprovalNumber =
        await _mapController?.getSatelliteImageApprovalNumber();
    if (null != mapContentApprovalNumber) {
      state.approvalNumberWidget.add(Text(mapContentApprovalNumber));
    }
    if (null != satelliteImageApprovalNumber) {
      state.approvalNumberWidget.add(Text(satelliteImageApprovalNumber));
    }
    update();
    print('地图审图号（普通地图）: $mapContentApprovalNumber');
    print('地图审图号（卫星地图): $satelliteImageApprovalNumber');
  }

  @override
  void dispose() {
    super.dispose();
    _mapController.disponse();
  }
}
